package hl.demosample.viewmodel.request

import androidx.lifecycle.MutableLiveData
import hl.demosample.app.network.apiService1
import hl.demosample.app.network.stateCallback.ListDataWelfareUiState
import me.hgj.jetpackmvvm.base.viewmodel.BaseViewModel
import me.hgj.jetpackmvvm.ext.requestNoCheck

/*
* path: DemoSample 
* Author: 86133
* Create: 2021-06-01 17:39
* Changes (from 2021-06-01)
* Desc
*/
class RequestWelfareViewModel:BaseViewModel() {
    var welfareData = MutableLiveData<ListDataWelfareUiState>()

    fun getWelfare(pageSize: Int, pageNum: Int) {
        requestNoCheck({ apiService1.welfare(pageSize, pageNum) }, {
            //请求成功
            val listWelfareDataUiState =
                ListDataWelfareUiState(error = false, listData = it.results)
            welfareData.value = listWelfareDataUiState
        }, {
            //请求失败
            val listWelfareDataUiState =
                ListDataWelfareUiState(error = true, listData = null)
            welfareData.value = listWelfareDataUiState
        })
    }
}